home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / dskhrdldr.lha / FileLoader-Seg.s < prev    next >
Encoding:
Text File  |  1980-01-12  |  3.2 KB  |  216 lines

  1. ; The FileLoader Segment,  a0=Pointer to FileName, a1=Memory to Load to
  2. ; a2 = MFM Buffer Space ($3400 Bytes please) and d0 = Drive number
  3.  
  4. ; Cannot handle directories or FFS disks!!  Be Done Soon m8s, reshuffled
  5. ; by Mr. Spillage
  6.  
  7. ; Code taken out that german-book.
  8.  
  9.     Opt    c-
  10.     Section    "File Loader",Code_c
  11.     
  12.     IncDir    Df1:
  13.  
  14. Start    Movem.l    d0-d7/a0-a6,-(sp) 
  15.     Bsr    ResetAll
  16.  
  17.     Moveq    #0,d7
  18.     Lea    CommPnt(pc),a6
  19.     Move.l    a0,0(a6)
  20. NameLen    Add.b    #1,d7
  21.     Cmpi.b    #0,(a0)+
  22.     Bne    NameLen
  23.     Move.l    d7,4(a6)
  24.  
  25.     Lea    MFMPoint(pc),a6
  26.     Lea    FileAdd(pc),a5
  27.     Move.l    a1,0(a5)    
  28.     Move.l    a2,0(a6)
  29.     Move.w    d0,4(a6)    
  30.  
  31.     Add.w    d0,d0
  32.     Lea    Set0Track0(pc),a6
  33.     Tst.w    (a6,d0.w)
  34.     Bne    ZeroSet
  35.  
  36. SetTrack0    Moveq    #0,d0
  37.     Lea    DriveNumber(pc),a6
  38.     Move.w    (a6),d1
  39.     Bsr    DTrack+$20
  40.     Lea    DriveNumber(pc),a6
  41.     Move.w    (a6),d0
  42.     Add.w    d0,d0    
  43.     Lea    Set0Track0(pc),a6
  44.     St    (a6,d0.w)
  45.  
  46. ZeroSet    Lea    CommPnt(pc),a6
  47.     Sub.l    #1,4(a6)
  48.     Move.l    0(a6),a0
  49.     Move.l    4(a6),d0
  50.     Moveq    #0,d2
  51.     Move.l    d0,d1
  52.     Subq    #1,d1
  53.     
  54. HashLoop    Mulu    #13,d0
  55.     Move.b    (a0)+,d2
  56.     Bsr    Upper
  57.     Add.w    d2,d0
  58.     And.w    #$7ff,d0
  59.     Dbf    d1,HashLoop
  60.     
  61.     Divu    #72,d0
  62.     Swap    d0
  63.     Addq    #6,d0
  64.     Lea    Hash(pc),a6
  65.     Move.w    d0,(a6)
  66.     
  67.     Move.l    #880,d0
  68.     Bsr    LoadSec
  69.     
  70.     Move.l    MFMPoint(pc),a0
  71.     Moveq    #0,d0
  72.     Move.w    Hash(pc),d0
  73.     Lsl.w    #2,d0
  74.     Move.l    0(a0,d0),d0
  75.     Tst.l    d0
  76.     Beq    None
  77.     
  78. LoadLoop    Lea    Sector(pc),a6
  79.     Move.l    d0,(a6)
  80.     Bsr    LoadSec
  81.     
  82.     Move.l    CommPnt(pc),a0
  83.     Move.l    MFMPoint(pc),a1
  84.     Add.l    #432,a1
  85.     Move.l    CommLen(pc),d0
  86.     Cmp.b    (a1)+,d0
  87.     Bne    NextSec
  88.     Subq    #1,d0
  89.     
  90. NameLoop    Move.b    (a1)+,d2
  91.     Bsr    Upper
  92.     Move.w    d2,d1
  93.     Move.b    (a0)+,d2
  94.     Bsr    Upper
  95.     Cmp.b    d1,d2
  96.     Bne    NextSec
  97.     Dbf    d0,NameLoop
  98.     Bra    SectorOK
  99.     
  100. NextSec    Move.l    MFMPoint(pc),a6
  101.     Move.l    496(a6),d0
  102.     Tst.l    d0
  103.     Bne    LoadLoop
  104.  
  105.     Moveq    #3,d0
  106.     Lea    DriveNumber(pc),a6
  107.     Move.w    (a6),d1
  108.     Bsr    DTrack+$20
  109.     
  110. None    Bra    Quit
  111.     
  112. SectorOK    Move.l    MFMPoint(pc),a6
  113.     Cmp.l    #2,508(a6)
  114.     Bne    NoDir
  115.     Bra    Quit
  116.     
  117. NoDir    Bra    SecLoop1
  118.     
  119. SecLoop    
  120. SecLoop1    Lea    SectorHead(pc),a6
  121.     Tst    (a6)
  122.     Bne    CopySect
  123.     St    (a6)
  124.     Bra    GetHeader
  125. CopySect    Move.l    MFMPoint(pc),a6
  126.     Move.l    12(a6),d7
  127.     Lea    FileAdd(pc),a6
  128.     Move.l    (a6),a4
  129.     Add.l    d7,(a6)
  130.     Subq    #1,d7
  131.     Move.l    MFMPoint(pc),a5
  132.     Add.l    #$18,a5
  133. CopSec    Move.b    (a5)+,(a4)+
  134.     Dbf    d7,CopSec
  135. JustLoad    Move.l    MFMPoint(pc),a6
  136.     Move.l    16(a6),d0
  137.     Tst.l    d0
  138.     Beq    Quit
  139.     Lea    Sector(pc),a6
  140.     Move.l    d0,(a6)
  141.     Bsr    LoadSec
  142.     Bra    SecLoop
  143.     
  144. GetHeader    Move.l    MFMPoint(pc),a6
  145.     Move.l    81*4(a6),d0
  146.     Lea    FileLength(pc),a6
  147.     Move.l    d0,(a6)
  148.     Bra    JustLoad
  149.     
  150. Quit    Movem.l    (sp)+,d0-d7/a0-a6 
  151.     Moveq    #0,d0      
  152.     Rts
  153.             
  154. LoadSec    Movem.l    d0-d7/a0-a6,-(sp)
  155.     Lea    SectorLoad(pc),a6
  156.     Move.w    d0,(a6)
  157.     Moveq    #1,d0
  158.     Lea    DriveNumber(pc),a6
  159.     Move.w    (a6),d1
  160.     Bsr    DTrack+$20
  161.     Moveq    #2,d0
  162.     Move.w    SectorLoad(pc),d1
  163.     Move.l    MFMPoint(pc),a0
  164.     Move.l    a0,a1
  165.     Add.l    #$200,a1
  166.     Bsr    DTrack+$20
  167.     Movem.l    (sp)+,d0-d7/a0-a6
  168.     Rts    
  169.     
  170. Upper    Cmp.b    #"a",d2
  171.     Blo    UpperX
  172.     Cmp.b    #"z",d2
  173.     Bhi    UpperX
  174.     Sub.w    #$20,d2
  175.     
  176. UpperX    Rts
  177.  
  178. ResetAll    Lea    Sector(pc),a6
  179.     Move.l    #0,(a6)+
  180.     Move.w    #0,(a6)+
  181.     Move.l    #0,(a6)+
  182.     Move.l    #0,(a6)+
  183.     Lea    SectorLoad(pc),a6
  184.     Move.w    #0,0(a6)
  185.     Move.w    #0,6(a6)
  186.     Move.l    #0,8(a6)
  187.     Rts
  188.     
  189.  
  190. MFMPoint    Dc.l    0
  191. DriveNumber    Dc.w    0
  192. Set0Track0    Dc.w    0
  193. Set0Track1    Dc.w    0
  194. Set0Track2    Dc.w    0
  195. Set0Track3    Dc.w    0
  196. SectorLoad    Dc.w    0
  197. FileAdd    Dc.l    $d0000
  198. SectorHead    Dc.w    0
  199. FileLength    Dc.l    0
  200.  
  201. Sector    Dc.l    0
  202. Hash    Dc.w    0
  203. CommPnt    Dc.l    0
  204. CommLen    Dc.l    0
  205.  
  206. DTrack    Incbin    MyMateMarmite/DTrakkerFINAL-Seg
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.